#include "Comm.hpp"
#include <unistd.h>
int main()
{
    Fifo fifo(Path); // 创建命名管道类的实例，名字叫 fifo
    int rfd = open(Path, O_RDONLY);
    if (rfd < 0)
    {
        cerr << "open failed,errno:" << errno << ",errstring"
             << strerror(errno) << endl;
        return 1;
    }
    cout << " open success " << endl;
    char buffer[1024];
    while (true)
    {
        ssize_t n = read(rfd, buffer, sizeof(buffer) - 1);
        if (n > 0)
        {
            buffer[n] = 0;
            cout << "cilent say:" << buffer << endl;
        }
        else if (n == 0)
        {
            cout << "cilent quit,me too!!" << endl;
            break;
        }
        else
        {
            cerr << "read failed,errno:" << errno << ",errstring:" << strerror(errno) << endl;
            break;
        }
    }

    close(rfd);
    return 0;
}